package com.zmzncs.lmtc.module.order.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zmzncs.lmtc.common.pojo.PageInfo;
import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.util.JsonUtil;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.order.pojo.order_Info.*;
import com.zmzncs.lmtc.module.order.pojo.orderCompareResult.OrderCompareResultDTO;
import com.zmzncs.lmtc.module.order.pojo.orderCompareResult.OrderCompareResultVO;
import com.zmzncs.lmtc.module.order.service.OrderHistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * <p>
 * 客户-信息 前端控制器
 * </p>
 *
 * @author
 * @since 2020-09-01
 */
@Api(tags = "订单历史")
@RestController
@RequestMapping("/order/orderHistory")
@Slf4j
public class OrderHistoryController {

    @Autowired
    private OrderHistoryService orderHistoryService;

    @ApiOperation(value = "订单对账结果")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @GetMapping(value = "selectOrderCompareResult")
    public Rest<PageInfo<OrderCompareResultVO>> selectOrderCompareResult(OrderHistoryForm orderHistoryForm) {
        IPage<OrderCompareResultDTO> orderCompareResultDTOS = orderHistoryService.selectTableOrderHistory(orderHistoryForm);
        PageInfo<OrderCompareResultVO> pageInfo = JsonUtil.pageTransform(orderCompareResultDTOS, OrderCompareResultVO.class);
        return RestUtil.success(pageInfo);
    }



    @ApiOperation(value = "处理操作")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @PostMapping(value = "result-pass")
    public Rest orderResultPass(Long id, int status, String passMsg) {
        int  result = orderHistoryService.orderResultPass(id, status, passMsg);
        if(result>0){
            return RestUtil.success("操作成功！");
        }else{
            return RestUtil.success("操作失败！");
        }

    }


}

